package com.slofzx.nuoda.evaluation.project.controller;

import com.slofzx.nuoda.evaluation.project.dto.ProjectReportDetailYearDTO;
import com.slofzx.nuoda.evaluation.project.vo.ProjectReportDetailYearVO;
import com.slofzx.nuoda.evaluation.project.service.ProjectReportDetailYearService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.slofzx.nuoda.common.controller.BaseController;
import com.slofzx.nuoda.common.vo.AjaxResultVO;
import com.slofzx.nuoda.common.vo.PageResultVO;
import com.slofzx.nuoda.common.enums.ServiceResult;

import java.util.*;

import javax.annotation.Resource;

/**
 * 评价结果年份数据控制层
 *
 * @author nuoda
 * @menu 评价结果年份数据
 * @since 2023-12-27 17:40:27
 */
@RestController
@RequestMapping("/project_report_detail_year")
public class ProjectReportDetailYearController extends BaseController {
    /**
     * 服务对象
     */
    @Autowired
    private ProjectReportDetailYearService projectReportDetailYearService;

    /**
     * 通过查询条件查询列表数据
     *
     * @param dto 查询参数
     * @return 列表数据
     */
    @GetMapping("/data")
    public AjaxResultVO<List<ProjectReportDetailYearVO>> queryList(ProjectReportDetailYearDTO dto) {
        List<ProjectReportDetailYearVO> dataList = projectReportDetailYearService.queryList(dto);
        return PageResultVO.newSuccessResult(dataList, dto.getCount());
    }

    /**
     * 创建数据
     *
     * @param dto 参数数据
     * @return 操作结果
     */
    @ResponseBody
    @PostMapping(value = "/create")
    public AjaxResultVO create(@RequestBody ProjectReportDetailYearDTO dto) {
        ServiceResult resultEnum = projectReportDetailYearService.create(dto);
        return AjaxResultVO.getInstance(resultEnum);
    }

    /**
     * 数据更新
     *
     * @param dto
     * @return 操作结果
     */
    @ResponseBody
    @PostMapping(value = "/update")
    public AjaxResultVO update(@RequestBody ProjectReportDetailYearDTO dto) {
        ServiceResult resultEnum = projectReportDetailYearService.update(dto);
        return AjaxResultVO.getInstance(resultEnum);
    }

    /**
     * 删除数据
     *
     * @param id
     * @return 操作结果
     */
    @ResponseBody
    @PostMapping(value = "/delete")
    public AjaxResultVO delete(@RequestParam String id) {
        ServiceResult resultEnum = projectReportDetailYearService.deleteById(id);
        return AjaxResultVO.getInstance(resultEnum);
    }

    /**
     * 查询单个数据
     *
     * @return id对应数据
     */
    @ResponseBody
    @GetMapping(value = "/info/{id}")
    public AjaxResultVO<ProjectReportDetailYearVO> queryById(@PathVariable String id) {
        ProjectReportDetailYearVO vo = projectReportDetailYearService.queryById(id);
        return AjaxResultVO.newSuccessResult(vo);
    }

}
